package cn.inyaa.admin.sys.controller;

import cn.inyaa.admin.config.CacheService;
import cn.inyaa.admin.sys.service.InyaaSysConfigService;
import com.inyaa.base.bean.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/config")
@RequiredArgsConstructor
public class InyaaSysConfigController {

    private final InyaaSysConfigService inyaaSysConfigService;
    private final CacheService cacheService;

    @PostMapping("/save")
    public BaseResult<String> save(@RequestBody Map<String, String> req) {
        inyaaSysConfigService.save(req);
        return BaseResult.success();
    }

    @GetMapping("/findAll")
    public BaseResult<Map<String, Object>> getConfig(Integer type) {
        Map<String, Object> config = cacheService.getConfig(type);
        return BaseResult.success(config);
    }
}
